import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/main_page/me/page/setting_page.dart';

class UserDrawerView extends StatefulWidget {
  const UserDrawerView({Key? key}) : super(key: key);

  @override
  _UserDrawerViewState createState() => _UserDrawerViewState();
}

class _UserDrawerViewState extends State<UserDrawerView> {
  List titleList = [
    '签到领钱',
    '创作者中心',
    '草稿箱',
    '签到领钱',
    '膳食管理',
    '最近浏览',
    '采购清单',
    '课程 • 单子书',
    '钱包',
    '优惠券',
    '订单',
  ];

  List<Widget> widgetList = [];

  @override
  Widget build(BuildContext context) {
    widgetList.add(Container(
      height: 50,
      padding: EdgeInsets.only(left: 18, top: 10),
      child: Text(
        '更多',
        style: TextStyle(
            fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold),
      ),
    ));

    titleList.forEach((element) {
      widgetList.add(SizedBox(
        height: 40,
        child: TextButton(
            onPressed: () {
              Navigator.pop(context);
            },
            child: Row(
              children: [
                Image.asset(
                  'assets/images/common/navi_item_messages.png',
                  width: 22,
                  height: 22,
                  color: Colors.black,
                ),
                SizedBox(width: 10,),
                Text(element,style: TextStyle(fontSize: 13,color: AppColors.black),),
              ],
            )),
      ));
      if(element == '草稿箱' || element == '采购清单' || element == '订单'){
        widgetList.add(
          Divider(), //分割线
        );
      }
    });

    widgetList.add(
      Container(
        padding: EdgeInsets.only(left: 20,bottom: 20),
        child: Row(
          children: [
            TextButton(
                onPressed: () {
                  Navigator.pop(context);
                  Navigator.of(context)
                      .push(MaterialPageRoute(builder: (_) {
                    return SettingPage();
                  }));
                },
                child: Column(
                  children: [
                    Image.asset(
                      'assets/images/common/navi_item_setting@2x.png',
                      width: 22,
                      height: 22,
                      color: Colors.black,
                    ),
                    SizedBox(height: 10,),
                    Text('设置',style: TextStyle(fontSize: 13,color: AppColors.black),),
                  ],
                )),
            TextButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: Column(
                  children: [
                    Image.asset(
                      'assets/images/common/binding_servicer_normal@2x.png',
                      width: 22,
                      height: 22,
                      color: Colors.black,
                    ),
                    SizedBox(height: 10,),
                    Text('联系我们',style: TextStyle(fontSize: 13,color: AppColors.black),),
                  ],
                )),
          ],
        ),
      ),
    );

    return SizedBox(
      width: MediaQuery.of(context).size.width * 0.7,
      child: Drawer(
        child: ListView(
          children: widgetList,
        ),
      ),
    );
  }
}
